package com.aispeech.jarpc;

public enum EArpcState {
    S_UNKNOWN(-1),
    S_OK(0),
    S_EOF(1),
    S_INTERNAL_ERROR(2),
    S_CONNECT_FAILED(3),
    S_CONNECTION_BROKEN(4),
    S_START_FAILED(5),
    S_NOT_IN_FEEDING(6),
    S_FEED_ERROR(7),
    S_MSG_OVERLOAD(8),
    S_TIMEOUT(9),
    S_CONNECTION_CLOSED(10);

    private final int value;

    EArpcState(int value) {
        this.value = value;
    }

    public static EArpcState from(int value) {
        EArpcState state = S_UNKNOWN;

        for (EArpcState eaRpcState : EArpcState.values()) {
            if (eaRpcState.value == value) {
                state = eaRpcState;
                break;
            }
        }

        return state;
    }

    public int getValue() {
        return value;
    }
}
